// 封装本地化token
const TOKEN_NAME = 'hm-toutiao-token'
const CHANNEL_NAME = 'hm-toutiao-channel'
const HISTORY_NAME = 'hm-toutiao-history'

export function setStorageToken(payload) {
  localStorage.setItem(TOKEN_NAME, JSON.stringify(payload))
}
export function getStorageToken() {
  return JSON.parse(localStorage.getItem(TOKEN_NAME)) || {}
}
export function removeStorageToken() {
  localStorage.removeItem(TOKEN_NAME)
}

// 封装本地频道
export function setStorageChannel(payload) {
  localStorage.setItem(CHANNEL_NAME, JSON.stringify(payload))
}
export function getStorageChannel() {
  return JSON.parse(localStorage.getItem(CHANNEL_NAME))
}

// 封装本地搜索历史记录
export function setStorageHistory(payload) {
  localStorage.setItem(HISTORY_NAME, JSON.stringify(payload))
}
export function getStorageHistory() {
  return JSON.parse(localStorage.getItem(HISTORY_NAME)) || []
}
